import { useRouter } from 'vue-router';

export const useNavigation = () => {
    const router = useRouter();

    // 跳转到指定类别页面
    const navigateToCategory = (category) => {
        const tags = encodeURIComponent(category);
        router.push(`/category/${tags}`);
        console.log(tags);
    };

    // 跳转到书籍详情页面
    const navigateToBook = (id) => {
        router.push({ path: `/bookInformation/${id}` });
    };

    // 跳转到作者详情页面
    const navigateToAuthor = (author) => {
        router.push({ path: `/home/WriterCenter/${author}` });
    };

    return {
        navigateToCategory,
        navigateToBook,
        navigateToAuthor
    };
};